package com.prs.crm.dao.flow.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.flow.WorkFlowAndPersonDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.approval.Application;
import com.prs.crm.domain.assets.AssetsLingYong;
import com.prs.crm.domain.assets.AssetsRevert;
import com.prs.crm.domain.assets.AssetsScrap;
import com.prs.crm.domain.ca.work.ArticleTook;
import com.prs.crm.domain.ca.work.PurchaseApply;
import com.prs.crm.domain.document.Draft;
import com.prs.crm.domain.flow.WorkFlow;
import com.prs.crm.domain.flow.WorkFlowAndPerson;
import com.prs.crm.domain.receipt.ReceiptRegister;

public class WorkFlowAndPersonDaoImpl extends BaseDaoImpl<WorkFlowAndPerson> implements WorkFlowAndPersonDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<WorkFlowAndPerson> getWorkFlowAndPerson(WorkFlow workFlow,
			PurchaseApply purchaseApply) {
		Criteria criteria=this.getSession().createCriteria(WorkFlowAndPerson.class);
		criteria.add(Restrictions.eq("workFlow", workFlow));
		criteria.add(Restrictions.eq("purchaseApply", purchaseApply));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<WorkFlowAndPerson> getWorkFlowAndPersons(WorkFlow workFlow,
			ReceiptRegister receiptRegister) {
		Criteria criteria=this.getSession().createCriteria(WorkFlowAndPerson.class);
		criteria.add(Restrictions.eq("workFlow", workFlow));
		criteria.add(Restrictions.eq("receiptRegister",receiptRegister));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<WorkFlowAndPerson> getWorkFlowAndPersonByDraft(
			WorkFlow workFlow, Draft draft) {
		Criteria criteria=this.getSession().createCriteria(WorkFlowAndPerson.class);
		criteria.add(Restrictions.eq("workFlow", workFlow));
		criteria.add(Restrictions.eq("draft",draft));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<WorkFlowAndPerson> getWorkFlowAndPersonByApplication(
			WorkFlow workFlow, Application application) {
			Criteria criteria=this.getSession().createCriteria(WorkFlowAndPerson.class);
			criteria.add(Restrictions.eq("workFlow", workFlow));
			criteria.add(Restrictions.eq("application", application));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<WorkFlowAndPerson> getWorkFlowAndPersonByArticleTook(
			WorkFlow workFlow, ArticleTook articleTook) {
		Criteria criteria=this.getSession().createCriteria(WorkFlowAndPerson.class);
		criteria.add(Restrictions.eq("workFlow", workFlow));
		criteria.add(Restrictions.eq("articleTook", articleTook));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<WorkFlowAndPerson> getWorkFlowAndPersonByAssetsLingYong(
			WorkFlow workFlow, AssetsLingYong assetsLingYong) {
		Criteria criteria=this.getSession().createCriteria(WorkFlowAndPerson.class);
		criteria.add(Restrictions.eq("workFlow", workFlow));
		criteria.add(Restrictions.eq("assetsLingYong", assetsLingYong));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<WorkFlowAndPerson> getWorkFlowAndPersonByAssetsRevert(
			WorkFlow workFlow, AssetsRevert assetsRevert) {
		Criteria criteria=this.getSession().createCriteria(WorkFlowAndPerson.class);
		criteria.add(Restrictions.eq("workFlow", workFlow));
		criteria.add(Restrictions.eq("assetsRevert", assetsRevert));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<WorkFlowAndPerson> getWorkFlowAndPersonByAssetsScrap(
			WorkFlow workFlow, AssetsScrap assetsScrap) {
		Criteria criteria=this.getSession().createCriteria(WorkFlowAndPerson.class);
		criteria.add(Restrictions.eq("workFlow", workFlow));
		criteria.add(Restrictions.eq("assetsScrap", assetsScrap));
		return criteria.list();
	}
}
